/**
 * @module wx
 */

import os from '@packages/lib-os';
import { execWxJob } from './util';

/**
 * 用来模拟用户行为，以达到视频/音频自动播放的目的
 * input autofocus无法触发
 * @export
 * @param {Function} fn
 */
export function mockUserAction(fn) {
    if (os.wechatPhone) {
        execWxJob(() => {
            const { wx } = window;
            wx &&
                wx.ready &&
                wx.ready(() => {
                    wx.getNetworkType({
                        success: () => {
                            fn && fn();
                        },
                    });
                });
        });
    } else {
        fn && fn();
    }
}
